<?php
/**
 * Created by PhpStorm.
 * User: CYJiao
 * Date: 6/11/15
 * Time: 16:53
 */
?>

<script>
    $(function(){
        var ehr = $('#ehr');
        $(window).resize(function(){
            ehr.treegrid('resize', {
                width:function(){
                    return document.body.clientWidth;
                },
                height:function(){
                    return document.body.clientHeight;
                }
            });
        });

        ehr.treegrid({
            url:'<?php echo CController::createUrl('eHR/getEHRS',array('pk_outpatient_id'=>$pk_outpatient_id)) ;?>',
            method:'get',
            fitColumns:true,
            rownumbers:true,
            idField:'id',
            treeField:'date',
            fit:true,
            striped:true,
            remoteSort:false,
            singleSelect:true,
            toolbar:'#toolbar-ehr',
            nowrap:false,
            border:false,
            onDblClickRow :function(rowIndex){
                if(rowIndex.iconCls=='icon-ok' || rowIndex.iconCls=='icon-cancel'){
                    addPatientTab('历史病历','<?php echo Yii::app()->request->baseUrl; ?>/index.php?r=eHR/getPatientEHRContent&pk_outpatient_ehr_id='+rowIndex.ehr_id,'icon-ehr');
                }
            }
        });
    });

    function refresh(){
        $('#ehr').treegrid('load',{
            url: '<?php echo CController::createUrl('eHR/getEHRS',array('pk_outpatient_id'=>$pk_outpatient_id)) ;?>'
        });
    }

</script>

<table id="ehr" class="easyui-treegrid">
    <thead>
    <tr>
        <th data-options="field:'date'">病历时间</th>
    </tr>
    </thead>
</table>
<div id="toolbar-ehr">
    <table style="border-spacing:0">
        <tr style="margin-bottom: 5px;">
            <td>
                <div class="easyui-linkbutton" data-options="iconCls:'icon-add'" onclick="addPatientTab('添加病历','<?php echo CController::createUrl('eHR/addPatientEHR',array('pk_outpatient_id'=>$pk_outpatient_id)) ;?>','icon-ehr')">添加病历</div>
                <div class="easyui-linkbutton" data-options="iconCls:'icon-reload'" onclick="refresh();">刷新列表</div>
            </td>
        </tr>
    </table>
</div>